'use strict';

const { Controller } = require('uni-cloud-router');

module.exports = class MpController extends Controller { 
	
	// 首页
	async getinfo () {
	
		const hot = await this.db.collection('usemall-app-spec').get();
		hot.code=0
		return hot;
	}
	
	async setinfo () {
	
		
		var data = this.ctx.data.all
		var dataarr ={
			user_id:data.user_id,
			front_img:data.front_img.url,
			side_img:data.side_img.url,
			back_img:data.back_img.url,
			
			
			
			front_imgobj:data.front_img,
			side_imgobj:data.side_img,
			back_imgobj:data.back_img,
			
			
			sex_id:data.info.sex_id,
			height:data.info.height,
			weight:data.info.weight,
			age:data.info.age,
			user_name:data.info.user_name,
			groups:data.body,
			create_time: Date.now(),
		}		
		const hot = await this.db.collection('usemall-user-size').add(dataarr)
		
		return hot;
	}
	
	async getsize () {
		let data ={}
		if(this.ctx.data.uid){
			data.user_id=this.ctx.data.uid
		}else{
			data._id=this.ctx.data.id
		}
		const hot = await this.db.collection('usemall-user-size').where(data).get();
		hot.code=0
		return hot;
	}
	
	async remove() {
		const hot = await this.db.collection('usemall-user-size').doc(this.ctx.data.id).remove()
		hot.code=0
		return hot;
	}
	
	
}
